package com.joker.repository;

//会员用户创建展会

import com.mysql.cj.xdevapi.JsonArray;
import net.sf.json.JSONObject;

import java.sql.*;
import java.util.ArrayList;
import java.util.Date;

public class UserCreatZh {

    String name=null;
    Connection connection= null;
    JsonArray array=new JsonArray();

    ResultSet resultSet=null;
    ArrayList<JSONObject> list=new ArrayList<>();
    public int show(String s1, String s2, String s3, String s4, String d1,String d2){
        try {
            Class.forName("com.mysql.jdbc.Driver");
            String url="jdbc:mysql://localhost:3306/huizhan?useUnicode=true&characterEncoding=utf-8&serverTimezone=UTC";
            String root="root";
            String password="123456";
            try {
                connection = DriverManager.getConnection(url,root,password);
            } catch (SQLException throwables) {
                throwables.printStackTrace();
            }
            String sql="insert into zhanhui (useid,ZH_name,ZG_name,xinxi,begin_date,end_date) values (?,?,?,?,?,?)";
            PreparedStatement preparedStatement = connection.prepareStatement(sql);
            preparedStatement.setString(1,s1);
            preparedStatement.setString(2,s2);
            preparedStatement.setString(3,s3);
            preparedStatement.setString(4,s4);
            preparedStatement.setString(5,d1);
            preparedStatement.setString(6,d2);

            int i=preparedStatement.executeUpdate();


        } catch (ClassNotFoundException | SQLException e) {
            e.printStackTrace();
        }finally {
            try {
                connection.close();
            } catch (SQLException throwables) {
                throwables.printStackTrace();
            }
        }
        return 0;
    }

}
